<%@ taglib prefix="c" uri="/WEB-INF/tlds/hdiv-c.tld"%>
<%@ taglib prefix="form" uri="/WEB-INF/tlds/hdiv-spring-form-3_0_4.tld"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>

<c:url value="selecClienteBanco.html" var="seleccionarClienteBanco"/>

<%@ page contentType="text/form;charset=windows-1252"%>
<script src="javascript/jquery.displaytag-ajax-1.2.js" type="text/javascript"></script>
  <script type="text/javascript">  
    
    $(function() {
        $('span.pagelinks>a, table#dispTable>thead>tr>th>a').live('click', function(){
            $.get($(this).attr('href'), function(responseText, status, xmlHttpRequest){
                $('#displayTagDiv').html($('#displayTagDiv', responseText).html());
                }
            )            
            return false;
        })
    });
    
    $(document).ready(function(){                
        $.getJSON("<c:url value='selecClienteBanco.html'/>", {accion : "searchDesCliente" },function(data){
            $("#desCliente").autocomplete({source:data});
        });        
        $("form").submit(function(){
            return false;
        });
        //$("#desPunto").focus(function(){$("#desPunto").bestupper();});
        $("#desCliente").bestupper({
            clear:false
        });
        $("#mostrar").click(function(){ 
            $.get("<c:url value='selecClienteBanco.html'/>",{accion:"buscarClienteATM",desCliente:document.forms[0].desCliente.value}, function(responseText, status, xmlHttpRequest){
                $('#displayTagDiv').html($('#displayTagDiv', responseText).html());
                }
            )            
        });
        $("#guardar").click(function(){
          $.getJSON("<c:url value='selecClienteBanco.html'/>",{accion:"saveClienteHermeticAtm"},function(data){
            if(data=="0"){
              $("#errorContainer").html("Se registr&oacute; los clientes exitosamente").css("color","blue").css("font-weight","bold").fadeOut(20000);
            }else{
              $("#errorContainer").html("Ocurri&oacute; un error!!! por favor int&eacute;ntelo nuevamente").css("color","red").css("font-weight","bold").fadeOut(20000);
            }
          });
        });
        $("#cerrar").click(function(){
          self.close();
        });
    });
    function setChkCliente(checkObj){
        var idChkObj = checkObj.checked;
        if(idChkObj){
            $.getJSON("<c:url value='selecClienteBanco.html'/>", {accion : "selectCodClienteATM",codCliente: checkObj.value});
        }else{
            $.getJSON("<c:url value='selecClienteBanco.html'/>", {accion : "deselectCodClienteATM",codCliente: checkObj.value});
        }        
    }   
      
    function setChkTodos(checkTodos){
        var booCheckTodos = "Check Object: "+ checkTodos.checked;
        $.get("<c:url value='selecClienteBanco.html'/>",{accion:"selectTodosATM",codTodos:checkTodos.checked}, function(responseText, status, xmlHttpRequest){            
            $('#displayTagDiv').html($('#displayTagDiv', responseText).html());
            }
        )        
    }
      
  </script>
  <meta http-equiv="Content-Type" content="text/form;charset=windows-1252">
  
<body>
<form:form modelAttribute="form" name="form" action="#">
<form:hidden path="accion"/>
<form:hidden path="cliente"/>
    <table id="fullheighttable" width="500px" align="center">
        <tr>
            <td align="left" valign="top" class="fondo_contenido padtop16left21">
                <table>
                    <tr>
                        <td class="verdana11bazul">Cliente</td>
                        <td>
                            <form:input path="desCliente" cssClass="fondo_txtbox258"/>
                        </td>
                        <td>
                            <input type="button" class="boton" id="mostrar" value="Mostrar"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" style="color:red;font-weight:bold;text-align:left;">
                        Lista de Clientes.
                        </td>
                    </tr>
                    <tr>
                      <td colspan="3">
                        <div id="errorContainer"></div>
                      </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                        <input type='checkbox' id='chkTodos' onclick='setChkTodos(this)'/> Todos                        
                        <div id="displayTagDiv">
                        <c:set var="count" value="0"/>
                        <display:table name="listClientesBanco" class="its" 
                                       pagesize="10" id="Cliente"
                                       requestURI="/selecClienteBanco.html">
                            
                            <display:column title="Sel">
                                <c:set var="count" value="${count+1}"/>
                                <input type="checkbox" id="_chk${Cliente.codCliente}" name="_chk" value="${Cliente.codCliente}" onclick="setChkCliente(this);" ${Cliente.chkMarca}/>
                            </display:column> 
                            <display:column escapeXml="true" style="width:350px;text-align:left;" property="nombre" title="Descripci&oacute;n"/>
                        </display:table>
                        </div>
                        </td>
                    </tr>                    
                    <tr>
                        <td colspan="3" align="center">                
                            <input type="button" value="Guardar" id="guardar" class="boton"/>&nbsp;&nbsp;&nbsp;
                            <input type="button" value="Cerrar" id="cerrar" class="boton"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr><td>

        </td></tr>
    </table>
</form:form>
</body>